package com.song.gui.layoutManager;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Frame;

/**
 * BorderLayout——边框布局管理器
 *
 * @author SongRenShuo
 * @date 2024/02/22
 */
public class BorderLayoutDemo {

    public static void main(String[] args) {
        Frame frame = new Frame("BorderLayt");
        frame.setBounds(100, 100, 400, 300);
        // frame.setLayout(new BorderLayout()); //设置 frame的布局为BorderLayout,默认也是此布局

        Button btn1 = new Button("button1");
        Button btn2 = new Button("button2");
        Button btn3 = new Button("button3");
        Button btn4 = new Button("button4");
        Button btn5 = new Button("button5");

        btn1.setBackground(Color.blue);
        btn2.setBackground(Color.yellow);
        btn3.setBackground(Color.pink);
        btn4.setBackground(Color.green);
        btn5.setBackground(Color.red);

        frame.add(btn1,BorderLayout.EAST);
        frame.add(btn2,BorderLayout.NORTH);
        frame.add(btn3,BorderLayout.SOUTH);
        frame.add(btn4,BorderLayout.WEST);
        frame.add(btn5);

        frame.setVisible(true);
    }

}
